#include<bits/stdc++.h>
#define int long long
using namespace std;
namespace IO
{
	template<typename T>
	void read(T &_x){_x=0;int _f=1;char ch=getchar();while(!isdigit(ch)) _f=(ch=='-'?-1:_f),ch=getchar();while(isdigit(ch)) _x=_x*10+(ch^48),ch=getchar();_x*=_f;}
	template<typename T,typename... Args>
	void read(T &_x,Args&...others){Read(_x);Read(others...);}
	const int BUF=20000000;char buf[BUF],to,stk[32];int plen;
	#define pc(x) buf[plen++]=x
	#define flush(); fwrite(buf,1,plen,stdout),plen=0;
	template<typename T>inline void print(T x){if(!x){pc(48);return;}if(x<0) x=-x,pc('-');for(;x;x/=10) stk[++to]=48+x%10;while(to) pc(stk[to--]);}
}
using namespace IO;
const int mod = 1e9+7,mod1 = 11451,mod2 = 181817,N = 20000;
int n = 5000,d,k,o,p;
signed main()
{
	freopen("holiday.in","w",stdout);
	srand(time(0));
	d = rand()%n+1,k = rand()%n+1; o = rand()+1; p = rand()*d%mod;
	cout<<n<<" "<<k<<" "<<d<<endl; 
	for(int i = 1;i <= n;i++) cout<<o*d%N+1-10000<<' ',o = (o*i+mod1)%mod2; 
	cout<<'\n';
	for(int i = 1;i < n;i++) cout<<p*d%n+1<<' ',p = (p*i+mod1)%mod2; 
	cout<<'\n';
	return 0;
}



